package com.zj.demomybatisplus.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zj.demomybatisplus.model.User;
import com.zj.demomybatisplus.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: zj
 * @Date: 2019/3/24 13:07
 * @Description:
 */
@RestController
public class UserController {
    @Autowired
    UserService userService;

    @GetMapping("/test")
    public Object test() {
        return userService.selectById( "1" );
    }

    @GetMapping("/test1")
    public Object test1(@RequestParam("username") String username) {
        return userService.selectOneByUsername( username );
    }

    @GetMapping("/test2")
    public Object test2(@RequestParam("current") Integer current) {
        IPage<User> iPage =userService.selectPage( new Page<User>(current,3),new QueryWrapper<>(  ));
        return iPage.getRecords();
    }

}
